﻿@model PaginatedList<MVCCoreFramework.Models.ContosoUniversity.Student>

@{
    ViewData["Title"] = "Students";
}

<div class="row">      
    <div class="col-md-12">
        <div class="box">
            <div class="box-header with-border">
                <a asp-action="Create">Create New</a>
                <form asp-action="Index" method="get">
                    <div class="form-actions no-color">
                        <p>
                            Find by name: <input type="text" name="SearchString" value="@ViewData["currentFilter"]" />
                            <input type="submit" value="Search" class="btn btn-default" /> |
                            <a asp-action="Index">Back to Full List</a>
                        </p>
                    </div>
                </form>
            </div>
            <div class="box-body">
                <table class="table">
                    <thead>
                        <tr>
                            <th>
                                <a asp-action="Index" asp-route-sortOrder="@ViewData["NameSortParm"]" asp-route-currentFilter="@ViewData["CurrentFilter"]">Last Name</a>
                            </th>
                            <th>
                                First Name
                            </th>
                            <th>
                                <a asp-action="Index" asp-route-sortOrder="@ViewData["DateSortParm"]" asp-route-currentFilter="@ViewData["CurrentFilter"]">Enrollment Date</a>
                            </th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model)
                {
                    <tr>
                        <td>
                            @Html.DisplayFor(modelItem => item.LastName)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.FirstMidName)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.EnrollmentDate)
                        </td>
                        <td>
                            <a asp-action="Edit" asp-route-id="@item.ID">Edit</a> |
                            <a asp-action="Details" asp-route-id="@item.ID">Details</a> |
                            <a asp-action="Delete" asp-route-id="@item.ID">Delete</a>
                        </td>
                    </tr>
        }
                    </tbody>
                </table>
            </div>
            <div class="box-footer clearfix">
                @{
        var prevDisabled = !Model.HasPreviousPage ? "disabled" : "";
        var nextDisabled = !Model.HasNextPage ? "disabled" : "";
                }

                <a asp-action="Index"
                   asp-route-sortOrder="@ViewData["CurrentSort"]"
                   asp-route-page="@(Model.PageIndex - 1)"
                   asp-route-currentFilter="@ViewData["CurrentFilter"]"
                   class="btn btn-default @prevDisabled">
                    Previous
                </a>
                <a asp-action="Index"
                   asp-route-sortOrder="@ViewData["CurrentSort"]"
                   asp-route-page="@(Model.PageIndex + 1)"
                   asp-route-currentFilter="@ViewData["CurrentFilter"]"
                   class="btn btn-default @nextDisabled">
                    Next
                </a>
            </div>
        </div>    

        </div>
    </div>


